#ifndef GBFORM_H
#define GBFORM_H

#include "../../src/systems/Event System/IListener.h"
#include "..\IRenderable.h"
#include "GBWidget.h"
#include <vector>

class GBLabel;
class GBForm : public GBWidget, public IListener
{
private:
	bool m_bIsActive;
	bool m_bIsFocused;

	std::vector<GBWidget*> m_children;	// For the tree (FORM Holds WIDGETS)

	void RegisterEvents(bool bIsActive);

public:
	GBForm();
	~GBForm();

	GBWidget* operator[](int index) { return GetChild(index); }

	void Update(const float fTimeStep);
	void Render();
	void HandleEvent(Event* pEvent);
	void AddWidget(GBWidget* pWidget);
	void RemoveWidget(GBWidget* pWidget);
	void RemoveWidgetAll();

	void Copy(const GBWidget* pRef);

	bool IsFocused() const { return m_bIsFocused; }
	bool IsActive() const { return m_bIsActive; }

	void SetFocused(bool bIsFocused) { m_bIsFocused = bIsFocused; }
	void SetActive(bool bIsActive) 
	{ 
		m_bIsActive = bIsActive; 
		RegisterEvents(m_bIsActive);
	}

	unsigned GetNumChildren() const { return (unsigned)m_children.size(); }

	GBWidget* GetChild(int index) const
	{
		if(index < 0 || index >= (int)m_children.size()) return NULL;
		return m_children[index];
	}

	WidgetType Type() const { return WIDGET_TYPE_FORM; }
};

#endif